import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

// 引入nprogress第三方依赖
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 导入axios
import axios from 'axios'

import treeTable from 'vue-table-with-tree-grid'

// 导入阿里字体图标
import './assets/fonts/iconfont.css'

// 导入全局样式
import './assets/css/global.css'

// 引入vue-quill-editor依赖包
import VueQuillEditor from 'vue-quill-editor'

// require styles 导入vue-quill-editor的样式文件
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 将富文本编辑器全局注册
Vue.use(VueQuillEditor)

// 自定义全局过滤器
Vue.filter('dateFormat', (date) => {
const dt = new Date(date)
const y = dt.getFullYear()
const m = (dt.getMonth() + 1 + '').padStart(2, '0')
const d = (dt.getDate() + '').padStart(2, '0')
const hh = (dt.getHours() + '').padStart(2, '0')
const MM = (dt.getMinutes() + '').padStart(2, '0')
const ss = (dt.getSeconds() + '').padStart(2, '0')
return `${y}-${m}-${d} ${hh}:${MM}:${ss}`
})

// 设置请求拦截器 处理权限标识问题 显示进度条NProgress.start()
axios.interceptors.request.use((config) => {
config.headers.Authorization = window.sessionStorage.getItem('token')
NProgress.start()
return config
})

// 设置响应拦截器 隐藏进度条NProgress.done()
axios.interceptors.response.use((config) => {
NProgress.done()
return config
})

// 设置请求api的基准地址
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

Vue.config.productionTip = false

// 手动全局注册
Vue.component('tree-table', treeTable)

// 全局挂载axios
Vue.prototype.$http = axios

new Vue({
router,
render: h => h(App)
}).$mount('#app')
